Skip to content

fix(browser): goto 重试覆盖裸 'Page not found:' 失效身份#1869

Open
huanghe wants to merge 1 commit into
jackwener:mainfrom
huanghe:pr/stale-page-identity
Open

fix(browser): goto 重试覆盖裸 'Page not found:' 失效身份#1869
huanghe wants to merge 1 commit into
jackwener:mainfrom
huanghe:pr/stale-page-identity

Conversation

@huanghe
Copy link
Copy Markdown
Contributor

@huanghe huanghe commented Jun 6, 2026

问题

Page.goto() 已有「stale page identity 自动重试」逻辑:当缓存的 targetId 失效(标签被外部关闭、identity 被驱逐)时,丢弃死 id 并经 session lease 重试一次。

但判定函数 isStalePageIdentityError() 只匹配错误信息里包含 stale page identity 的情况。在并发 adapter 调用下,扩展有时只抛出 Page not found: <id>(不带 — stale page identity 后缀)。这类错误没被识别为「身份失效」,于是不会重试——同一个死 targetId 被反复发送,导致后续调用连环失败。

改动

isStalePageIdentityError() 放宽为同时匹配 Page not found::

-  return message.includes('stale page identity');
+  return message.includes('stale page identity') || message.includes('Page not found:');

这样 goto() 在收到裸 Page not found: 时也会丢弃失效身份、重试一次。重试本身是安全的:只是清掉缓存 targetId 后让扩展的 session lease 重新解析到活标签(已有逻辑),_page 为空时仍照旧直接抛错、不重试。

测试

新增用例 retries on a bare "Page not found:" error without the stale-identity suffix:

  • 有本修复:src/browser/page.test.ts 25 个用例全部通过。
  • 去掉本修复(对照):该用例失败,第二次 goto() 直接抛 Page not found: deadbeef,证明它精确覆盖了新分支。

npx tsc --noEmit 通过。

…oto retry

The goto() stale-identity retry only matched errors containing 'stale page
identity'. Under concurrent adapter calls the extension can reject with just
'Page not found: <id>' (no suffix) when the cached targetId was evicted — those
were not retried, so a dead targetId cascaded into repeated failures across calls.

Broaden isStalePageIdentityError() to also match 'Page not found:' so goto()
drops the stale identity and retries once through the session lease.
@huanghe huanghe force-pushed the pr/stale-page-identity branch from d09bfa1 to c2978a7 Compare June 6, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant